<template>
  <view class="content" :style="{ paddingTop: statusBarHeight + 'px' }">
    <uni-nav-bar title="点采订单" fixed :border="false" height="88rpx" left-icon="left"
      @clickLeft="onClickLeft"></uni-nav-bar>
    <scroll-view class="scroll-view_H" scroll-y @refresherrefresh="refresherrefreshFn" refresher-enabled="true"
      :show-scrollbar="false" @scrolltolower="lower" :refresher-triggered="triggered" enhanced
      style="height: calc(100% - var(--window-top) - 88rpx)">
      <view class="infoCard" v-for="item in orderList" :key="item.id"
        @click.stop="$navTo('./noWaitOrderDetail', { id: item.id, status: item.status })">
        <view class="info">
          <view class="name">点采编号：{{ item.number }}</view>
          <view class="tokenNum">
            <view class="count1">点采总额：{{ item.totalMoney }}元</view>
            <view class="count">商品条目：{{ item.entryCount }}</view>
          </view>
          <view class="tokenNum">
            <view class="count1">点采时间：{{ item.orderTime | parseTime }}</view>
            <view class="count" v-if="item.status == '0'">状态：未审核</view>
            <view class="count" v-if="item.status == '1'">状态：审核通过</view>
            <view class="count" v-if="item.status == '2'">状态：审核失败</view>
          </view>
          <view class="tokenNum">
            <view class="count1">采购员：{{ item.username }}</view>
            <view class="count">
              <view class="btnBox  btn type-1">详情</view>
            </view>
          </view>
        </view>
      </view>
      <uni-load-more :status="loading" v-if="orderList.length > 0"></uni-load-more>
      <view
        style="width: 100%;height: 100%;background-color: #f7f7f7;display: flex;justify-content: center;align-items: center;"
        v-if="orderList.length == 0">
        <image src="/static/index/nonedata.png" mode="aspectFill" style="width: 400rpx;height: 400rpx;"></image>
      </view>
    </scroll-view>
  </view>
</template>

<script>
import { reqNonstandardOrderList } from '@/apis/member.js'
export default {
  name: "MemberInfo",
  data() {
    return {
      orderList: [],
      page: {
        pageNum: 1,
        pageSize: 15
      },
      triggered: false, // 是否触发下拉刷新
      loading: 'loading', // 是否触发上拉加载
    }
  },
  onLoad() {
    this.reqNonstandardOrderList()
  },
  onShow() {
  },
  methods: {
    refresherrefreshFn() {
      this.page.pageNum = 1
      this.triggered = true
      this.orderList = []
      this.loading = "loading";
      this.reqNonstandardOrderList();
    },
    async reqNonstandardOrderList() {
      const res = await reqNonstandardOrderList({ ...this.page })
      if (res.code === 200) {
        this.orderList = [...this.orderList, ...res.data.list]
        this.nextPage = res.data.nextPage
        console.log('orderList:', this.orderList);
        this.triggered = false
        if (res.data.isLastPage) {
          this.loading = "noMore"
        }
      }
    },
    lower() {
      if (this.loading == "noMore") {
        return;
      }
      this.page.pageNum++;
      this.loading = "loading";
      this.reqNonstandardOrderList();
    },
  }
}
</script>

<style></style>
<style lang="scss" scoped >
.content {
  height: 100vh;
  // background-color: #d3e3fd;
}

view {
  box-sizing: border-box;
}

.infoCard {
  display: flex;
  font-size: 26rpx;
  margin: 20rpx;
  padding: 20rpx 20rpx;
  align-items: center;
  height: 240rpx;
  line-height: 50rpx;
  border-radius: 20rpx;
  background-color: #d3e3fd;
  // border: 1px solid #619cfc;

  .goodsImg {
    margin-right: 20rpx;
    width: 180rpx;
    height: 180rpx;
    border-radius: 50%;
    background-color: #eee;
  }

  .info {
    flex: 1;
  }

  .tokenNum {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    text-align: left;

    .count1 {
      width: 65%;
    }

    .count {
      width: 35%;
    }
  }
}

.btnBox {
  height: 50rpx;
  width: 100rpx !important;
  text-align: center;
  border-radius: 6rpx;
  line-height: 50rpx !important;
  margin-left: 30rpx !important;
  // margin: 0 auto;
}
</style>
